package edu.chl.hajo.shop.core;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.OneToOne;
import javax.persistence.Table;

/**
 * A Product
 * @author hajo
 */
@Entity
@Table(name = "Products")
public class Product extends AbstractEntity {

    private String name;
    private double price;
    
    @OneToOne(mappedBy = "product", cascade={CascadeType.PERSIST, CascadeType.REMOVE})
    private OrderItem orderItem;

    public Product(String name, double price) {
        this.name = name;
        this.price = price;
    }
        public Product() {

    }

    

    public Product(Long id, String name, double price) {
        super(id);
        this.name = name;
        this.price = price;
    }

    public String getName() {
        return name;
    }

    public double getPrice() {
        return price;
    }
    
        /**
     * @return the orderItem
     */
    public OrderItem getOrderItem() {
        return orderItem;
    }

    /**
     * @param orderItem the orderItem to set
     */
    public void setOrderItem(OrderItem orderItem) {
        this.orderItem = orderItem;
    }
     
    @Override
    public String toString() {
        return "Product{" + "id=" + getId() + ", name=" + name + ", price=" + price + '}';
    }
}
